package hn.sigit.dao.hnd.administrative;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.jboss.seam.Component;

import hn.sigit.model.hnd.administrative.HND_NaturalPerson;
import hn.sigit.model.ladm.party.LA_Party;
import hn.sigit.dao.SigitDAO;

public class HND_NaturalPersonDAO extends SigitDAO<HND_NaturalPerson> {
	private static final long serialVersionUID = 1L;

	public static List<HND_NaturalPerson> loadNaturalPersonParties() {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		return loadNaturalPersonParties(commonsDatabase);
	}
	public static List<LA_Party> loadParties() {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		return loadParties(commonsDatabase);
	}
	
	@SuppressWarnings("unchecked")
	public static List<HND_NaturalPerson> loadNaturalPersonParties(Session session) {
		Criteria criteria = session.createCriteria(HND_NaturalPerson.class);
		return (List<HND_NaturalPerson>)criteria.list();
	}
	@SuppressWarnings("unchecked")
	public static List<LA_Party> loadParties(Session session) {
		Criteria criteria = session.createCriteria(LA_Party.class);
		criteria.add(Restrictions.in("extParty", loadNaturalPersonParties()));
		
		return (List<LA_Party>)criteria.list();
	}
	
}
